/* CSS变量定义 */
:root {
    /* 颜色 */
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --border-color: #dee2e6;
    --hover-color: #2980b9;

    /* 间距 */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* 布局 */
    --navbar-height: 60px;
    --sidebar-width: 250px;
    --container-max-width: 1200px;
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* 导航栏样式 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--navbar-height);
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.navbar-container {
    max-width: var(--container-max-width);
    height: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-menu {
    display: flex;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: var(--spacing-md);
}

.nav-links a {
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: var(--primary-color);
    color: white;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: all 0.3s;
}

/* 主要内容区样式 */
.main-container {
    margin-top: var(--navbar-height);
    max-width: var(--container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding: var(--spacing-md);
    display: flex;
    gap: var(--spacing-lg);
}

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    position: sticky;
    top: calc(var(--navbar-height) + var(--spacing-md));
    height: calc(100vh - var(--navbar-height) - 2 * var(--spacing-md));
}

.category-nav {
    background-color: white;
    padding: var(--spacing-md);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-nav h2 {
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.category-list a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 4px;
    transition: all 0.3s;
}

.category-list a:hover,
.category-list a.active {
    background-color: var(--primary-color);
    color: white;
}

/* 新闻网格样式 */
.news-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.news-card {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.news-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.news-content {
    padding: var(--spacing-md);
}

.news-content h3 {
    margin-bottom: var(--spacing-sm);
    font-size: 1.2rem;
}

.news-content p {
    color: #666;
    font-size: 0.9rem;
}

/* 页脚样式 */
.footer {
    background-color: #2c3e50;
    color: white;
    padding: var(--spacing-xl) 0;
    margin-top: var(--spacing-xl);
}

.footer-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xl);
}

.footer-section h4 {
    margin-bottom: var(--spacing-md);
    color: var(--secondary-color);
}

.footer-section ul {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.footer-section a {
    opacity: 0.8;
    transition: opacity 0.3s;
}

.footer-section a:hover {
    opacity: 1;
}

.copyright {
    text-align: center;
    padding-top: var(--spacing-xl);
    margin-top: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        width: 100%;
        flex-direction: column;
        background-color: white;
        padding: var(--spacing-md);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
    }

    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
    }

    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        height: auto;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #f8f9fa;
        --bg-color: #1a1a1a;
        --border-color: #2c3e50;
    }

    .navbar,
    .category-nav,
    .news-card {
        background-color: #2c3e50;
    }

    .news-content p {
        color: #adb5bd;
    }
}
